<template>
  <div class="data-permission">
    <el-form-item label="数据范围">
      <el-select v-model="scope" placeholder="请选择数据范围">
        <el-option label="全部数据" value="all" />
        <el-option label="本部门数据" value="dept" />
        <el-option label="本部门及以下数据" value="deptAndDown" />
        <el-option label="仅本人数据" value="self" />
        <el-option label="自定义" value="custom" />
      </el-select>
    </el-form-item>

    <template v-if="scope === 'custom'">
      <el-form-item label="数据条件">
        <div 
          v-for="(condition, index) in conditions" 
          :key="index"
          class="condition-item"
        >
          <el-select v-model="condition.field" placeholder="字段">
            <el-option label="部门ID" value="deptId" />
            <el-option label="用户ID" value="userId" />
            <el-option label="角色ID" value="roleId" />
          </el-select>
          
          <el-select v-model="condition.operator" placeholder="操作符">
            <el-option label="等于" value="eq" />
            <el-option label="不等于" value="ne" />
            <el-option label="大于" value="gt" />
            <el-option label="小于" value="lt" />
            <el-option label="包含" value="in" />
            <el-option label="模糊匹配" value="like" />
          </el-select>
          
          <el-input v-model="condition.value" placeholder="值" />
          
          <el-button type="danger" @click="removeCondition(index)">
            <el-icon><Delete /></el-icon>
          </el-button>
        </div>
        
        <el-button type="primary" @click="addCondition">
          <el-icon><Plus /></el-icon>添加条件
        </el-button>
      </el-form-item>
    </template>
  </div>
</template> 